// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: ST Logo Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// Aliases
private alias 3 : TYPE_STLOGO

private alias object.value0 : object.timer
private alias object.value1 : blink.timer

// Function declarations

// Tables


event ObjectMain
	switch object.state
	case 0
		Stage[0].ActiveLayer=2
		object.inkEffect = INK_ALPHA
		object.alpha = 255
		if object.timer < 10
			object.timer++
		else
			object.timer = 0
			object.state++
		end if
		break
	case 1
		if object.timer < 50
			object.timer++
		else
			object.timer = 0
			object.state++
		end if
		break
	case 2
		if object.alpha > 0
			object.alpha -= 4
		else
			PlayMusic(0)
			object.state++
		endif
		break
	case 3
		temp0 = inputPress.ButtonA
		temp0 |= inputPress.ButtonB
		temp0 |= inputPress.ButtonC
		temp0 |= inputPress.Start
		if temp0 == 1
			object.state ++
			stage.activeList = PRESENTATION_STAGE
			stage.listPos = 3
		endif
		break
	case 4
		if object.alpha < 255
			music.volume --
			object.alpha += 4
		else
			LoadStage()
		endif
		break
	endswitch
end event


event ObjectDraw
	

	object.animationTimer++
	if object.animationTimer > 7
		object.animationTimer = 0
		object.frame ^= 1
	endif


	if object.state == 0
		DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 256)
	else
		temp0 = 80
		drawSpriteScreenXY(2, screen.xcenter, temp0)
		temp0 += 90

		if object.state < 4
			blink.timer ++
		else
			blink.timer += 2
		endif
		if blink.timer > 31
			blink.timer = 0
		endif
		if blink.timer < 15
			drawSpriteScreenXY(3, screen.xcenter, temp0)
		endif

		temp0 += 30
		drawSpriteScreenXY(object.frame, screen.xcenter, temp0)

		temp1 = 44
		temp1 += 8
		temp0 = screen.ysize
		temp0 -= 16
		drawSpriteScreenXY(6, temp1, temp0)
		temp1 = screen.xsize
		temp1 -= 50
		temp1 -= 8
		temp0 += 8
		drawSpriteScreenXY(5, temp1, temp0)

		temp0 = 65
		drawSpriteScreenXY(7, screen.xcenter, temp0)
		temp0 += 31
		drawSpriteScreenXY(8, screen.xcenter, temp0)
		temp0 += 34
		temp1 = screen.xcenter
		temp1 += 16
		drawSpriteScreenXY(9, temp1, temp0)
		DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)
	endif
end event


event ObjectStartup
	object.alpha = 255
	LoadSpriteSheet("Title/Title.gif")
	SetMusicTrack("TitleEGGMAN.ogg", 0, 1)

	SpriteFrame(-20, -27, 40, 56, 116, 370)		//00 Eggman 1
	SpriteFrame(-20, -27, 40, 56, 157, 370)		//01 Eggman 2

	SpriteFrame(-80, -71, 161, 143, 512, 1)		//02 Eggman Logo

	SpriteFrame(-49, -5, 98, 9, 1, 380)		//03 PRESS BUTTON
	SpriteFrame(-57, -5, 114, 9, 1, 390)		//04 TOUCH TO START

	SpriteFrame(-50, -3, 100, 7, 1, 405)		//05 Version Number
	SpriteFrame(-44, -12, 89, 24, 1, 413)		//06 Copyright

	SpriteFrame(-30, -7, 61, 14, 512, 145)		//07 BOSS
	SpriteFrame(-45, -7, 91, 14, 512, 160)		//08 ATTACK
	SpriteFrame(-9, -9, 19, 19, 512, 175)		//09 +
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
